package com.zhiyou100.controller;

import java.io.IOException;

import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.zhiyou100.model.ResponseObject;
import com.zhiyou100.service.AjaxService;

@Controller
public class AjaxController {
	@Autowired
	private AjaxService as;
	@RequestMapping("/ZhuCe")
	public void checkUser(String usernameJson,HttpServletResponse resp) throws IOException {
		System.out.println("Ajax接收到的数据"+usernameJson);
		String code = as.checkUser(usernameJson);
		System.out.println("code: "+code);
		resp.getWriter().write(code);
	}
	@RequestMapping("/ZhuCe2")
	@ResponseBody
	public ResponseObject checkUser2(String usernameJson,HttpServletResponse resp) throws IOException {
		System.out.println("Ajax接收到的数据"+usernameJson);
		ResponseObject respObj = as.checkUser2(usernameJson);
		return respObj;
	}
	@RequestMapping("/UserMsg")
	@ResponseBody
	public ResponseObject findUserById(String id) {
		ResponseObject ro = as.findUserById(id);
		System.out.println("ro: "+ro);
		return ro;
	}
	@RequestMapping("/twoLevel")
	@ResponseBody
	public ResponseObject twoLevel(String val) {
		System.out.println("二级联动Controller: "+val);
		ResponseObject ro = as.teoLevel(val);
		System.out.println("ro: "+ro);
		return ro;
	}
	
}




